home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-22 | 3.6 KB | 255 lines | [TEXT/MPCC] |
- // LifeMenus.c
- // Handle the menu operation of Mike's Life
- // Copyright ©1995 Michael D. Crawford. All Rights Reserved.
- // 11 Jun 95 Mike Crawford crawford@scruznet.com
- //
- // Revision History:
- // 11 Jun 95 MDC New today
-
- #include <QDOffscreen.h>
- #include "LifeMenus.h"
- #include "LifeFile.h"
- #include "LifeMain.h"
- #include "Control.h"
- #include "MenuPrivate.h"
-
- Boolean ReallyQuit( void );
- short ReallyClose( void );
- void DoAboutBox( void );
-
- #define rAboutBoxID 128
- enum{
- kABOkButton = 1,
- kABDefUser,
- kABAboutPict,
- kABVersionUser
- };
-
- void AdjustMenus( void )
- {
- return;
- }
-
- void DoMenuChoice( long message )
- {
- short menuID;
- short menuItem;
-
- menuID = HiWord( message );
- menuItem = LoWord( message );
-
- switch( menuID ){
- case rAppleMenuID:
- DoAppleMenu( menuItem );
- break;
- case rFileMenuID:
- DoFileMenu( menuItem );
- break;
- case rEditMenuID:
- DoEditMenu( menuItem );
- break;
- case rLifeMenuID:
- DoLifeMenu( menuItem );
- break;
- }
-
- HiliteMenu( 0 );
-
- return;
- }
-
- void DoAppleMenu( short item )
- {
- Str255 daName;
- MenuHandle mHdl;
-
- switch( item ){
- case kAMAboutItem:
- DoAboutBox();
- break;
-
- case kAMDash1:
- break;
-
- default:
- mHdl = GetMenu( rAppleMenuID );
- if ( mHdl ){
- GetItem( mHdl, item, daName );
- OpenDeskAcc( daName );
- }
- break;
- }
-
- return;
- }
-
- void DoFileMenu( short item )
- {
- switch( item ){
- case kFMNewItem:
- DoNewWindow();
- break;
- case kFMOpenItem:
- break;
- case kFMCloseItem:
- DoCloseWindow();
- break;
- case kFMSaveItem:
- break;
- case kFMSaveAsItem:
- break;
- case kFMDash1:
- break;
- case kFMPageSetupItem:
- break;
- case kFMPrintItem:
- break;
- case kFMDash2:
- break;
- case kFMQuitItem:
- if ( ReallyQuit() ){
- TimeToQuit();
- }
- break;
- }
-
- return;
- }
-
- void DoEditMenu( short item )
- {
- switch( item ){
- case kEMUndoItem:
- break;
- case kEMDash1:
- break;
- case kEMCutItem:
- break;
- case kEMCopyItem:
- break;
- case kEMPasteItem:
- break;
- case kEMClearItem:
- break;
- case kEMDash2:
- break;
- case kEMSelectAllItem:
- break;
- case kEMDash3:
- break;
- case kEMPreferencesItem:
- break;
- case kEMDash4:
- break;
- case kEMShowClipboardItem:
- break;
- }
-
- return;
- }
-
- void DoLifeMenu( short item )
- {
- switch( item ){
- case kLMRunItem:
- StartRunning();
- break;
- case kLMStopItem:
- StopRunning();
- break;
- }
-
- return;
- }
-
- OSErr SetupMenus( void )
- {
- Handle mbarHdl;
- MenuHandle appleMenuHdl;
-
- mbarHdl = GetNewMBar( rMBarID );
- if ( !mbarHdl )
- return resNotFound;
-
- appleMenuHdl = GetMenu( rAppleMenuID );
- if ( !appleMenuHdl )
- return resNotFound;
-
- AddResMenu( appleMenuHdl, 'DRVR' );
-
- SetMenuBar( mbarHdl );
-
- DrawMenuBar();
-
- return noErr;
- }
-
- Boolean ReallyQuit( void )
- {
- // If there is a dirty window open, ask the user to Save/Cancel/Quit
- // STUB
-
- return true;
- }
-
- enum{
- kWTCancel,
- kWTSaveFirst,
- kWTClose
- };
-
- short ReallyClose( void )
- {
- // If the front window is dirty, ask the user to Save/Cancel/Close
- // STUB
-
- return kWTClose;
- }
-
- void DoCloseWindow( void )
- {
- short whatToDo;
- WindowPtr win;
- OSErr err;
-
-
- win = FrontWindow();
-
- if ( !win )
- return;
-
- whatToDo = ReallyClose();
-
- if ( whatToDo == kWTCancel )
- return;
-
- if ( whatToDo == kWTSaveFirst ){
- err = DoSave();
- if ( err )
- return;
- }
-
- CloseLifeWindow( win );
-
- return;
- }
-
- void DoAboutBox( void )
- {
- DialogPtr dlg;
- short item;
-
- // Stub install default outline and version user items
-
- dlg = GetNewDialog( rAboutBoxID, (DialogPtr)NULL, (WindowPtr)-1 );
-
- ShowWindow( dlg );
-
- do{
- ModalDialog( (ModalFilterUPP)NULL, &item );
- }while( item != kABOkButton );
-
- DisposeDialog( dlg );
-
- return;
- }